﻿using SocketUtil;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace 多线程和网络
{
    class Program
    {
        static void Main(string[] args)
        {
            //jingcheng();

            //duoxiancheng();

            SocketServer server = new SocketServer(8888);
            server.StartListen();

            SocketClient client = new SocketClient(8888);
            client.StartClient();

            Console.ReadKey();
        }

        public static void jingcheng()
        {

            //Process[] processes = Process.GetProcesses();
            //Console.WriteLine(processes.Length);
            //foreach(Process p in processes)
            //{
            //    //Console.WriteLine(p.ProcessName);
            //}

            // Process.Start("note");

            ProcessStartInfo psi = new ProcessStartInfo(@"D:\a1.txt");
            Process p = new Process();
            p.StartInfo = psi;

            p.Start();
        }

        /// <summary>
        /// 多线程，
        /// 
        /// 单线程带来的问题：
        /// 1，
        /// 2，
        /// 3，
        /// </summary>
        public static void duoxiancheng()
        {
            Thread th = new Thread(Test);
            th.Start();
            Console.WriteLine("主线程继续执行代码");
            Console.WriteLine("======================");
        }

        public static void Test()
        {
            for (int i = 0;i < 100; i++)
            {
                Console.WriteLine("新的线程中做一天耗时的事情");
            }
        }

        public static void socketserver()
        {
            Socket sev = new Socket(SocketType.Stream, ProtocolType.Tcp);

        }
    }
}
